<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Struct template stored_size</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../boost_container_header_reference.html#header.boost.container.options_hpp" title="Header &lt;boost/container/options.hpp&gt;">
<link rel="prev" href="store_hash.html" title="Struct template store_hash">
<link rel="next" href="throw_on_overflow.html" title="Struct template throw_on_overflow">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="store_hash.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_container_header_reference.html#header.boost.container.options_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="throw_on_overflow.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.container.stored_size"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template stored_size</span></h2>
<p>boost::container::stored_size</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_container_header_reference.html#header.boost.container.options_hpp" title="Header &lt;boost/container/options.hpp&gt;">boost/container/options.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> StoredSizeType<span class="special">&gt;</span> 
<span class="keyword">struct</span> <a class="link" href="stored_size.html" title="Struct template stored_size">stored_size</a> <span class="special">{</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.10.14.21.17.4"></a><h2>Description</h2>
<p>This option specifies the unsigned integer type that a user wants the container to use to hold size-related information inside a container (e.g. current size, current capacity).</p>
<p>
If the maximum capacity() to be used is limited, a user can try to use 8-bit, 16-bit (e.g. in 32-bit machines), or 32-bit size types (e.g. in a 64 bit machine) to see if some memory can be saved for empty vectors. This could potentially performance benefits due to better cache usage.</p>
<p>Note that alignment requirements can disallow theoretical space savings. Example: <code class="computeroutput">vector</code> holds a pointer and two size types (for size and capacity), in a 32 bit machine a 8 bit size type (total size: 4 byte pointer + 2 x 1 byte sizes = 6 bytes) will not save space when comparing two 16-bit size types because usually a 32 bit alignment is required for vector and the size will be rounded to 8 bytes. In a 64-bit machine a 16 bit size type does not usually save memory when comparing to a 32-bit size type. Measure the size of the resulting container and do not assume a smaller <code class="computeroutput"><a class="link" href="stored_size.html" title="Struct template stored_size">stored_size</a></code> will always lead to a smaller sizeof(container).</p>
<p>If a user tries to insert more elements than representable by <code class="computeroutput"><a class="link" href="stored_size.html" title="Struct template stored_size">stored_size</a></code>, vector will throw a <a class="link" href="length_error.html" title="Class length_error">length_error</a>.</p>
<p>If this option is not specified, <code class="computeroutput"><a class="link" href="allocator_traits.html" title="Struct template allocator_traits">allocator_traits</a>&lt;A&gt;::size_type</code> (usually std::size_t) will be used to store size-related information inside the container. </p>
<div class="refsect2">
<a name="id-1.3.10.14.21.17.4.7"></a><h3>Template Parameters</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">typename</span> StoredSizeType</pre>
<p>An unsigned integer type. It shall be smaller than than the size of the size_type deduced from <code class="computeroutput"><code class="computeroutput"><a class="link" href="allocator_traits.html" title="Struct template allocator_traits">allocator_traits</a></code>&lt;A&gt;::size_type</code> or the same type.</p>
</li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2018 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="store_hash.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_container_header_reference.html#header.boost.container.options_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="throw_on_overflow.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
